package com.paddyi.commons.http;

/**
 * HTTP结果封装
 *
 * @author Louis
 * @date Oct 29, 2018
 */
public class SsoHttpResult {

    private int code = 200;
    private String msg;
    private Object data;
    private String token = "";
    private String url;

    public static SsoHttpResult error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static SsoHttpResult error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static SsoHttpResult error(int code, String msg) {
        SsoHttpResult r = new SsoHttpResult();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public static SsoHttpResult ok(String msg) {
        SsoHttpResult r = new SsoHttpResult();
        r.setMsg(msg);
        return r;
    }

    public static SsoHttpResult ok(Object data) {
        SsoHttpResult r = new SsoHttpResult();
        r.setData(data);
        return r;
    }

    public static SsoHttpResult resultToken(String token, String url) {
        SsoHttpResult r = new SsoHttpResult();
        r.setToken(token);
        r.setUrl(url);
        return r;
    }

    public static SsoHttpResult ok() {
        return new SsoHttpResult();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
